package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Salary;
import cn.wolfcode.crm.domain.Employee;
import cn.wolfcode.crm.mapper.SalaryMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.ISalaryService;
import cn.wolfcode.crm.util.UserContext;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class SalaryImpl implements ISalaryService {
    @Autowired
    private SalaryMapper salaryMapper;


    @Override
    public void delete(Long id) {

        salaryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void save(Salary salary) {


        salaryMapper.insert(salary);

    }

    @Override
    public Salary get(Long id) {

        return salaryMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Salary> listAll() {
        return salaryMapper.selectAll();
    }

    @Override
    public void update(Salary salary) {
        salaryMapper.updateByPrimaryKey(salary);
    }


    @Override
    public PageInfo query(QueryObject qo) {
        //对比上面注释的内容
        //使用分页插件,每页显示数量
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        //查询结果集
        List<Salary> list = salaryMapper.selectForList(qo);
        return new PageInfo(list);

    }



}